# -*- coding: utf-8 -*-
"""
* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** 
*   Copyright 2014 Jan-Marwin Wollschläger                                   *
*                                                                            *
*   Licensed under the Apache License, Version 2.0 (the "License");          *
*   you may not use this file except in compliance with the License.         *
*   You may obtain a copy of the License at                                  *
*                                                                            *
*       http://www.apache.org/licenses/LICENSE-2.0                           *
*                                                                            *
*   Unless required by applicable law or agreed to in writing, software      *
*   distributed under the License is distributed on an "AS IS" BASIS,        *
*   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
*   See the License for the specific language governing permissions and      *
*   limitations under the License.                                           *
** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **  *  
"""

import os, sys

"""
	A script to generate the javadoc for this project.
	This script only works on the assumption that you are using a linux os.
"""


DEFAULT_PROJECT_PATH = "/home/marwin/Programming/StyreneJS/styrenejs/MolecularEditor/"
DEFAULT_DOC_PATH     = DEFAULT_PROJECT_PATH+"doc/"


if len(sys.argv) < 2:
	print 'Going to use default project path ' + DEFAULT_PROJECT_PATH


def generate_javadoc(file_path):
	os.chdir(DEFAULT_PROJECT_PATH)
	print 'In cwd'+os.getcwd()
	if os.path.exists(DEFAULT_DOC_PATH):
		os.system("rm -r "+DEFAULT_DOC_PATH)
	os.system("mkdir "+DEFAULT_DOC_PATH)
	os.system("cp *.* "+DEFAULT_DOC_PATH)
	os.chdir(DEFAULT_DOC_PATH)
	## os.system("rename pde java *.pde")  ## pde-File not compatible 
	os.system("javadoc *.java")            ## with javadoc-generator?
	os.system("rm *.java")
if len(sys.argv) < 2:
	generate_javadoc(DEFAULT_PROJECT_PATH)
else:
	for file_path in sys.argv[1:len(sys.argv)]:
		generate_javadoc(file_path)


print "Finished generating javadoc!"



